#pragma once
#include "Channel.h"
#include "EventLoop.h"
#include <string>

class EventLoop;

class Dispatcher
{
public:
    Dispatcher(EventLoop *evLoop) : m_evLoop(evLoop) {};
    virtual ~Dispatcher(){};
    //添加
    virtual int32_t add() = 0;
    //删除
    virtual int32_t remove() = 0;
    //修改
    virtual int32_t modify() = 0;
    //事件检测  2s
    virtual int32_t dispatch(int timeout  = 2) = 0;

    inline void setChannel(Channel *channel)
    {
        m_channel = channel;
    }

protected:
    Channel *m_channel;
    EventLoop *m_evLoop;
    std::string m_name = std::string();
};
